package page;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;


import com.opensymphony.xwork2.ActionSupport;

public class PageUtil extends ActionSupport implements ServletRequestAware{
	private HttpServletRequest request;
	private int pageNo;
	private int pageSize;
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	@Override
	public String execute() throws Exception {
		request.setAttribute("test", "execute");
		return SUCCESS;
	}
	
	public String print(){
		request.setAttribute("test", "print");
		return SUCCESS;
	}
	public String Page() throws ClassNotFoundException, SQLException{
		InfoDate info=new InfoDate();
		PageTool page=new PageTool(pageSize,pageNo);
		List<InFo> list = info.getInfo(page);
		page.setPageNum(new int[20]);
		request.setAttribute("list", list);
		request.setAttribute("page", page);
		return SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
	}
}
